/**
 * 基础对象编辑器 - Object 数组编辑
 * 2018年11月14日 15点06分
 * nico@coser.pub
 */
module.exports._init = function () {
  this._ObjectEditor = function (base) {
    try {
      if (!base.toSearilizeJson)
        base.toSearilizeJson = function (that) {
          let part = '';
          for (let k in that) {
            if (that.hasOwnProperty(k)) part += k + '=' + that[k] + ';';
          }
          return part;
        };

      if (!base.clone)
        base.clone = function (that) {
          return JSON.parse(JSON.stringify(that));
        };

      if (!base.mergeSearilizeJson)
        base.mergeSearilizeJson = function (searilizeJson, that) {
          searilizeJson.split(";").forEach(ck => {
            let kv = ck.split(';')[0].split('=');
            if (kv[0] !== "") that[kv[0]] = kv[1];
          });
          return that;
        };
    } catch (e) { }
  }
}